WiFiClient OTAUpdateClient;
Serial.println("start update");
#ifdef ESP32
httpUpdate.onStart(update_started);//当升级开始时
httpUpdate.onEnd(update_finished); //当升级结束时
httpUpdate.onProgress(update_progress); //当升级中
httpUpdate.onError(update_error); //当升级失败时
t_httpUpdate_return ret = httpUpdate.update(OTAUpdateClient, {{&otaUrl}});
#else
ESPhttpUpdate.onStart(update_started);//当升级开始时
ESPhttpUpdate.onEnd(update_finished); //当升级结束时
ESPhttpUpdate.onProgress(update_progress); //当升级中
ESPhttpUpdate.onError(update_error); //当升级失败时
t_httpUpdate_return ret = ESPhttpUpdate.update(OTAUpdateClient, {{&otaUrl}});
#endif
switch(ret) {
case HTTP_UPDATE_FAILED:  // 当升级失败
  Serial.println("[update] Update failed.");
  break;
case HTTP_UPDATE_NO_UPDATES:  // 当无升级
  Serial.println("[update] Update no Update.");
  break;
case HTTP_UPDATE_OK:  // 当升级成功
  Serial.println("[update] Update ok.");
  break;
}
